package pl.smath.web.client;

import java.util.Iterator;

import pl.smath.serializer.LatexSerializer;
import pl.smath.worksheet.results.OneStep;
import pl.smath.worksheet.results.Resolution;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;


public class ResolutionWidget extends Composite {

	private HTML resolutionHtml = new HTML();
	
	public ResolutionWidget() {
		initWidget(resolutionHtml);
		resolutionHtml.setWidth("100%");
	}
	
	public void setResolution(Resolution resolution){

		LatexSerializer ls = new LatexSerializer();
		Iterator<OneStep>	resolutionSteps = resolution.getSteps();
		
		int i=1;
		String html = "<div>";
		while(resolutionSteps.hasNext()){
			OneStep step = resolutionSteps.next();

			html += "<div class='resolution_widget_description'>" + i + ". " + step.getDescription() + 
			"</div><div class='math' style='font-size:18px; font-weight: normal; font-style:italic; text-align: left; margin: 5px 0px 15px 0px;'>" + 
				ls.serialize(step.getNode()) + "</div>";
			
			i++;
		}
		
		html += "</div>";
		
		resolutionHtml.setHTML(html);
		refreshMathSymbols();
	}
	
	/**
	 * Odswiezenie wzorow matematycznych na stronie
	 */
	public static native void refreshMathSymbols() /*-{
	  $wnd.jsMath.ProcessBeforeShowing();
	}-*/;
}
